<?php

try{
	$p->saleCheck();//查看产品是否在售
}catch(ProductInfoException $e){
	getOut("home.html",$e->getMessage());
}

$begintime = $p->getMinValidTime($begintime);/*产品有效起始日期*/
if($begintime==-1) getOut("home.html","无有效出行日期，请更换产品");
if(!$p->supply($memberID)) getOut("home.html","无购买权限");

if($begintime<date('Y-m-d')) $begintime = date('Y-m-d');
$xml = $s->Dynamic_Price_And_Storage($_SESSION['saccount'], $pid, $begintime, 1, 0, 1, $aid);
if($xml==105 || $xml==1065 || $xml==101) getOut($_SERVER['HTTP_REFERER'],"无有效出行日期，请更换产品");
$object = simpleXML_load_string($xml);
$jsprice = (int)$object->Rec->UUsprice;
//$storage = ((string)$object->Rec->UUstorage==-1) ? '不限':(string)$object->Rec->UUstorage;
$storage = $p->dayStorage($begintime);
$uprice = $p->uPrice_n($begintime);//返回产品零售价
$buynum = $p_info['buy_limit_low'] ? $p_info['buy_limit_low']:1;

$payMethod = $p_info['pay'];
$products=array();
$products[]=array(
	"pid"       => $pid,
	"id"        => "purchaseNum",
	"name"      => "tnum",
	"ttitle"    => $p_info['ttitle'].($p_info['v_time_limit']==0 ? '' : '(<span style="color:#F33">验票时间'.str_replace('|', '至', $p_info['v_time_limit']).'</span>)'),
	"buynum"    => $buynum,
	"jsprice"   => $jsprice,
	"uprice"    => $uprice,
	"tprice"    => $p_info['tprice'],
	"minTime"   => $begintime,
	"ddays"     => $p_info['ddays'],
	"buy_limit_low" => $p_info['buy_limit_low'],
	'buy_limit_up'  => $p_info['buy_limit_up'],
	'pay'       =>$p_info['pay'],
	'sendVoucher'=>$p_info['sendVoucher'],
	'order_start'=>$p_info['order_start'],
	'order_end'=>$p_info['order_end'],
    'reb'=>$p_info['reb'],
    'reb_type'=>$p_info['reb_type'],
    'storage'=>$storage,
	'area_id'=>$p_info['zone_id'],
);

// 获取分区信息
include('/var/www/html/new/d/module/common/Db.class.php');
$dbConf = include '/var/www/html/new/d/module/common/db.conf.php';// 远端服务器配置信息
\PFT\Db::Conf($dbConf['remote_1']);
$dbRows = \PFT\Db::fetch("select id,zone_name from pft_roundzone where id={$products[0]['area_id']} limit 1");
$products[0]['zone_name'] = $dbRows['zone_name'];


$rinfo  = $dbRows['use_date'].' '.$dbRows['bt'].'-'.$dbRows['et'];
// 产品有效期
$valid = _htmlValid($p_info);
$products[0]['valid'] = $valid;	

// 供应商信息
$str = "select dname,qq,mobile,cname from pft_member where id=".$p_info['sapply_did']." limit 1";
$GLOBALS['le']->query($str);
$a_info = $GLOBALS['le']->fetch_assoc();

// 产品说明
$timeTitle=($p_info['ddays']==0)?"有效期内，可预订当天门票":"有效期内，需提前".($p_info['ddays'])."天预订";
$unitT=$p_info['p_type']=="C"?"间":"张";
$tips=$p_info['ddays']>0?"需提前".$p_info['ddays']."天预订，":"可预订当日票，";
$tips.=$p_info['buy_limit_low']>0?$p_info['buy_limit_low'].$unitT."起订，":"1".$unitT."起订，";
if($p_info['p_type']=="A"){
	$tips.=($p_info['delaydays']>0)?"游玩日期起".$p_info['delaydays']."天内有效，":"游玩日期当日有效，";
}
$tips.=($p_info['status']!=0)?"<i>".($p_info['mdays']!=0?"自动":"人工")."确认</i>后生效，":"";
$tips=$tips.$p_info['notes'];


//金额
$v['tmoney'] = $m->tmoney($p_info['sapply_did']);//查询会员账户可用授信额度
$v['money'] = $m->money();//查询会员账户余额
$cinfos = $m->cinfos(-1);//查询常用联系人

if($v['tmoney']>$jsprice*$tnum){
	$paymodeCheck0="";
	$paymodeCheck1="";
	$paymodeCheck2="checked";
}elseif($v['money']>$jsprice*$tnum){
	$paymodeCheck0="checked";
	$paymodeCheck1="";
	$paymodeCheck2="";
}else{
	//$paymodeCheck0="checked";//暂时关闭支付宝
	$paymodeCheck0="";
	$paymodeCheck1="checked";
	$paymodeCheck2="";
}


$token = '6f0c6c49daa58b9d802189ac932dcd65';
$appid = base64_encode('www.12301.cc');


if($p_info['p_type']!='C') $land_f_info = $p_info;


$date_format = array('周日','周一','周二','周三','周四','周五','周六');
// print_r($products);
if($p_info['p_type']=='H'){// 演出类数据重组
	$var['venus_id'] = $p_info['venus_id'];
	$products_area = array();
	foreach($products as $row){
		$products_area[$row['area_id']]['list'][] = $row;
		$products_area[$row['area_id']]['total'] += 1;
	}
}

// print_r($products_area);

// include("tpl/pft_show/productOrder_show.html");
?>
<link type="text/css" rel="stylesheet" href="css/ui/Calendar.css" media="screen" />
<link type="text/css" rel="stylesheet" href="css/productOrder.css" media="screen" />
<script src="http://www.12301.cc/js/popBox.js"></script>
<style>
    #contactList{margin-bottom:10px; background:#f3faff; padding:10px;}
    #contactList li{ float:left; margin-right:20px; width:80px; text-align:center}
    #contactList li input{vertical-align:-2px; margin-right:2px;}
    .oper{ cursor:pointer}
    #popBox{ text-align:left; border:8px solid #767576; padding:20px;}
    .close{cursor:pointer;position:absolute; right:20px;top:10px;text-align:center;  font-size:14px; font-weight:bold;}
    #popBox h3{ color:#265895;font-weight:bold}
    #popBox textarea{ width:300px; height:80px;}
    #popBox  input.btn{padding:5px 10px; margin-right:20px; cursor:pointer; font-size:12px; }
    span.note_name{color:red;}
</style>
<div class="clay">
<input type="hidden" id="remaindMoney" value="<?=$v['money']?>"/>
<input type="hidden" id="remainTmoney" value="<?=$v['tmoney']?>"/>
<input type="hidden" id="minbuytnum" value="<?=$p_info['buy_limit_low']?>"/>
<input type="hidden" id="pay" value="<?=$p_info['pay']?>"/>
<input type="hidden" id="tourist_info" value="<?=$land_f_info['tourist_info']?>"/>
<form action="formSubmit_h.php" method="post" name="group">
<input type="hidden" name="pid" id="pid" value="<?=$pid?>"/>
<input type="hidden" name="aid" id="aid" value="<?=$aid?>"/>
<h2>
    <a target="_blank" href="scenicDetail.html?lid=<?=$p_info['lid']?>&did=<?=$memberID?>"><?=$p_info['ltitle']?></a>
</h2>
<div class="proBd">
<div class="contactW ">
    <h3 class="title">
        <span class="title">预订信息</span>
    </h3>
    <div class="box">
        <div class="ticketlist">
			<?include 'tpl/pft_show/productOrder_show.html'?>
        </div>
    </div>
</div>
        <!--管理常用联系人-->
<textarea id="pop_tpl" style="display:none">
<div id="popBox">
	<a class="close" onclick="popBox.close()">X</a>
	<h3>常用联系人管理</h3>
	<form  id="form1" action="../cutinfo.php" method="post" name="haha">
        <div id="contactList">
            <ul>
			   
                <?php foreach($cinfos as $cname=>$cmobile):?>
                <li>
                    <input id="testInput" type="checkbox" name="cutname[]" value="<?=$cname?>">
                    <span class="name"><?=$cname?></span>	
                </li>
                <?php endforeach;?>
				
            </ul>
            <p class="cl"></p>
        </div>
      <input  type="submit" id="Submit" value="删 除"/>
	</form>
 </div>
</textarea>
        <!--管理常用联系人结束-->





<div id="RecommendProducts" class="contactW"></div>
<div class="contactW ">
    <h3 class="title">
        <span class="title">联系人信息</span>（请准确填写联系人信息，我们将向联系人手机发送订单短信）
        <span class="save"><input type="checkbox" checked value="1" name="saveTo" class="inputText"/>保存到常用联系人</span>
		<a class="oper" orderid="" inputV="">操作</a>
    </h3>
    <div class="box">
        <?php if(count($cinfos)>0):?>
        <div id="contactList">
            <ul>
                <?php foreach($cinfos as $cname=>$cmobile):?>
                <li>
                    <input type="checkbox" value="<?=$cmobile?>">
                    <span class="name"><?=$cname?></span>
                </li>
                <?php endforeach;?>
            </ul>
            <p class="cl"></p>
        </div>
        <?php endif;?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>联系人：</span>
            <input type="text" class="inputText" id="ordername" autocomplete="off" name="ordername"/>
			<span class="note_name"></span>
		</p>
        <?if($_GET['pzp']){?>
        <p class="line">
				<span class="lTitle"><i class="red">*</i>身份证：</span>
				<input type="text" style="width:400px"  class="inputText" id="IDnum" name="IDnum">
			</p>
        <?}?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>手机号码：</span>
            <input type="text"  class="inputText" id="ordertel" name="ordertel">
            (接收订单短信，请务必正确填写)
        </p>
        <p class="line">
            <span class="lTitle">备注信息：</span>
            <input type="text" style="width:400px"  class="inputText" id="memo" name="memo">
        </p>
        <?if($m_info['cname']&&$m_info['ctel']){
                $cname=explode("|",$m_info['cname']);
                $ctel=explode("|",$m_info['ctel']);
                ?>
        <div class="contactWrap" id="contactWrap">
            <div class="content">
                <a class="closebtn"></a>
                <h4>您可以选择以下常用联系人：</h4>
                <ul>
                    <?for($i=count($cname)-1;$i>=0;$i--){
                            if(!$cname[$i]) continue;
                            ?>
                    <li>
                        <input type="checkbox" value="<?=$ctel[$i]?>" />
                        <span class="name"><?=$cname[$i]?></span>
                    </li>
                    <?}?>
                </ul>
                <p class="clear">&nbsp;</p>
            </div>
        </div>
        <?}?>
    </div>
</div>
<div class="">
    <h3 class="title"><span class="title">供应商信息</span></h3>
    <div class="box orderinfo">
        <p>
            <span>供应商名称：<?=$a_info['dname']?></span>
            <?php if($a_info['qq']):?>
            <span>QQ：<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?=$a_info['qq']?>&site=qq&menu=yes"><img onerror="this.parentNode.removeChild(this)" style="vertical-align:-5px" border="0" src="http://wpa.qq.com/pa?p=2:<?=$a_info['qq']?>:52" alt="点击这里给我发消息" title="点击这里给我发消息"/></a></span>
            <?php endif;?>
            <span>联系人：<?=$a_info['cname']?> <?=$a_info['mobile']?></span>
        </p>
    </div>
</div>
        <?php if($land_f_info['p_type']=='C'):?>
<div class="guest">
    <h3 class="title"><span class="title">入住信息</span></h3>
    <div class="box roomInfo">
        <?php if($land_f_info['tourist_info']>0):?>
        <p class="line">
            <span class="lTitle"><i class="red">*</i>入住人姓名：</span>
							<span class="roomDiv">
								<input type="text" class="inputText roomer gray" id="roomer" name="tourist_name_1" value="入住人1"/>
								<span class="ts">(请填写实际入住人姓名，每个房间只需填1位)</span>
							</span>
        </p>
        <?php endif;?>
        <div class="clear"></div>
        <p class="arriveTime line">
            <span class="lTitle"><i class="red">*</i>最晚到店：</span>
            <select class="" name="arriveTime" id="arriveTime">
                <option value="">请选择时间</option>
                <option>15:00</option>
                <option>16:00</option>
                <option>17:00</option>
                <option>18:00</option>
                <option>19:00</option>
                <option>20:00</option>
                <option>21:00</option>
                <option>22:00</option>
                <option>23:00</option>
                <option>24:00</option>
                <option>次日1:00</option>
                <option>次日2:00</option>
                <option>次日3:00</option>
                <option>次日4:00</option>
                <option>次日5:00</option>
            </select>
        </p>
    </div>
</div>
        <?php elseif($land_f_info['tourist_info']>0):?>
<div class="contactW ">
    <h3 class="title"><span class="title">旅客信息</span>（儿童证件号码请填写出生日期）</h3>
    <div class="box tourist">
        <?php if($land_f_info['tourist_info']==1):?>
        <div class="info">
            <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
							<span>
								<select class="tourist_type" style="display:none">
                                    <option value="1">成人</option>
                                </select>
							</span>
							<span>
								<label class="lt"><i class="red">*</i>姓名:</label>
								<input type="text" name="tourist_name_1" class="tourist_name">
							</span>
							<span>
								<label class="lt"><i class="red">*</i>身份证号:</label>
								<input type="text" name="tourist_cert_1" class="tourist_cert" >
							</span>
        </div>
        <?php else:?>
        <?php for($i=1;$i<=$buynum;$i++):?>
        <div class="info">
            <span>第<?=$i?>位游客</span>
                                <span>
                                    <select class="tourist_type">
                                        <option value="1">成人</option>
                                        <option value="0">儿童</option>
                                    </select>
                                </span>
                                <span>
                                    <label class="lt"><i class="red">*</i>姓名:</label>
                                    <input type="text" name="tourist_name_<?=$i?>" class="tourist_name">
                                </span>
                                <span>
                                    <label class="lt"><i class="red">*</i>身份证号:</label>
                                    <input type="text" name="tourist_cert_<?=$i?>" class="tourist_cert" >
                                </span>
        </div>
        <?php endfor;?>
        <?php endif?>
    </div>
</div>
        <?php endif;?>
<div class="contactW ">
    <h3 class="title"><span class="title">支付方式</span></h3>
    <div class="box">
        <?php if($p_info['apply_did']==$memberID):?>
        <p style="padding-left:20px;">预订自供产品，无需支付</p>
        <input type="hidden" value="3" name="paymode"/>
        <?php elseif ($payMethod==0):?>
        <p style="padding-left:20px;">现场支付</p>
        <input type="hidden" value="4" name="paymode" />
        <?php else:?>
        <p class="line pmodel" style="padding-left:20px;">
            <input class="paymode" type="radio" name="paymode" <?=$paymodeCheck2?> value="2" >
            <span class="credit">授信余额<label> (可用<em class="money">¥<?=$v['tmoney']/100?></em>)</label></span>
            </br>
        <?if(!$access['yd']):?>
        <input class="paymode" type="radio" value="0" <?=$paymodeCheck0?> name="paymode">
            <span>账户余额<label> (可用<em class="money">¥<?=$v['money']/100?></em>)</label></span>
            </br>
    <?endif;?>
    <input class="paymode" type="radio" value="1" <?=$paymodeCheck1?> name="paymode">
            <span>在线支付</span>
        </p>
        <?php endif;?>
        </div>
        </div>

        </div>
<div class="totalCount">
    <p class="con">
        <a href="#" class="submitBtn"></a>
        <i class="icon"></i>
        <?php if($p_info['p_type']!="C"):?>
        <span class="span1">门票数：<em id="sumtnum" class="num"><?=$buynum?></em>张</span>
        <?php endif;?>
        <span class="span2">总金额：<em id="summoney" class="num"><?=$buynum*$jsprice/100?></em>元</span>
    </p>
</div>
<div class="about">
    <h3 class="title"><span class="title">预订须知</span></h3>
    <div class="content">
        <h3>购票需知：</h3>
        <?=nl2br($p_info['jqts'])?>
        <h3>产品说明：</h3>
        <?=$tips?>
        <h3>取票信息：</h3>
        <?=$p_info['getaddr']?>
    </div>
</div>
        </form>
        </div>
        </div>
<script type="text/html" id="tourist_tmpl">
    <div class="info">
        <span>第{:num}位游客</span>
		<span>
			<select class="tourist_type">
                <option value="1">成人</option>
                <option value="0">儿童</option>
            </select>
		</span>
		<span>
			<label class="lt"><i class="red">*</i>姓名:</label>
			<input type="text" name="tourist_name_{:num}" class="tourist_name">
		</span>
		<span>
			<label class="lt"><i class="red">*</i>身份证号:</label>
			<input type="text" name="tourist_cert_{:num}" class="tourist_cert" >
		</span>
    </div>
</script>
<script type="text/html" id="pri_tmpl">
    <li>
        <div class='title'> {:date}({:weekT})</div>
        <input type="hidden" value="{:jsprice}"/>
        <div class="priItem">
            <span>¥{:jsprice}</span></br>
            <span>{:roomStatus}</span>
            <input type="hidden" class="tnum" value="{:tnum}"/>
        </div>
    </li>
</script>
<script type="text/html" id="roomer_tmpl">
    <input type="text" class="inputText roomer more gray" name="tourist_name_{:i}" value="入住人{:i}"/>
</script>
<script type="text/javascript" src="js/jquery.getareas.js" type="text/javascript"></script>
<script type="text/javascript" src="js/global/Date_func.js"></script>
<script type="text/javascript" src="js/ui/JsTpl.js"></script>
<script type="text/javascript" src="js/ui/PopWindow.js"></script>
<script type="text/javascript" src="js/form/Verify.js"></script>
        <?php if($p_info['p_type']=="C"):?>
<script type="text/javascript" src="js/ui/Calendar_hotel.js"></script>
        <?php else:?>
<script type="text/javascript" src="js/ui/Calendar.js"></script>
        <?php endif;?>
<script type="text/javascript" src="js/productOrder.js"></script>

        <?php if($p_info['p_type']=='F'):?>
<script>
    <? include '/var/www/html/new/d/module/link_product/child_tickets.js';?>
</script>
        <?php else:?>
<script>
    <? include '/var/www/html/new/d/module/link_product/link_product.js';?>
</script>
        <?php endif;?>


<script>
var popBox=new PopWindow();
var oper=function(elem,tag){
    var textarea=$(elem).parent().find("textarea");
    if(tag==1){
        $("#popBox .Ddstatus").val("1");
        $("#popBox form").submit();
    }else{
        $("#popBox .Ddstatus").val("2");
        $("#popBox form").submit();
    }
}
$("a.denybtn").click(function(){
    var applyid=$(this).attr("applyid");
    $("#applyid").val(applyid);
    popBox.open($("#pop_tpl").html())
    return false;
})

$("a.oper").click(function(){
    popBox.open($("#pop_tpl").text());
    return false;
});

</script>
<?
include("common/footer.html");?>